-
Couldn't load subscription status.
- Fork 1.8k
Extend implicit_saturating_sub lint
#12476
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extend implicit_saturating_sub lint
#12476
Conversation
|
r? @Manishearth rustbot has assigned @Manishearth. Use r? to explicitly pick a reviewer |
0ce4af5 to
0e63323
Compare
|
r? clippy still busy |
|
☔ The latest upstream changes (presumably #12451) made this pull request unmergeable. Please resolve the merge conflicts. |
0e63323 to
8a86926
Compare
|
Fixed merge conflict. r? @y21 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neat lint idea, but I'm not too sure what we want to do with the other implicit_saturating_{sub,add}/manual_saturating_arithmetic lints since they all seem really similar in their name and what they're intending to catch.
With this, we'd have four different lints that all look for manual (saturating) arithmetic
8a86926 to
1d26be1
Compare
manual_arithmetic_check lintimplicit_saturating_sub lint
1d26be1 to
b88a7a9
Compare
|
@y21: Instead of creating a new lint, I extended |
|
I haven't forgotten about this, will try to look at it again soon :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I completely forgot about this 😅 thanks for reminding me
6acaf81 to
91ebe40
Compare
|
Changes I pushed:
With this I think I covered all cases. Thanks a lot @y21! |
91ebe40 to
cd95c58
Compare
|
Fixed the test I added. Sorry for the delay. |
cd95c58 to
8aa4e51
Compare
|
Updated! |
|
Added MSRV check in const context. |
f18f779 to
a16510a
Compare
|
Fixed dogfood! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some small nits for the last change. I'll start the FCP in the meantime since this shouldn't really be a blocker for that I don't think
a16510a to
c25ec0e
Compare
|
Applied suggestions. |
c25ec0e to
9c6dd14
Compare
|
Rebased on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks all good to me now! Thanks for bearing with me for so long 😄
The FCP for the new lint has been open for a while but didn't get any comments (meaning no concerns), so I think we can just consider it complete now.
Mind squashing some of the commits? Specifically commits like dogfood etc. You can r=me with that
9c6dd14 to
754255a
Compare
|
Done. Time for r+. :D @bors r=y21 |
|
@GuillaumeGomez: 🔑 Insufficient privileges: Not in reviewers |
754255a to
2832faf
Compare
|
Ah apparently not. ^^' |
|
@bors r=y21 |
|
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
| /// | ||
| /// let result = a.saturating_sub(b); | ||
| /// ``` | ||
| #[clippy::version = "1.44.0"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this version should be 1.83 not 1.44? See #14653
Fixes #10070.
It can serve as base if we want to add equivalent checks for other arithmetic operations.
Also one important note: when writing this lint, I realized that I could check for wrong conditions performed beforehand on subtraction and added another part in the lint. Considering they both rely on the same checks, I kept both in the same place. Not sure if it makes sense though...
changelog: Extend
implicit_saturating_sublint